package part_1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;

public class Deflection {

	public static void main(String[] args) throws IOException {
		
		BufferedReader inputbuffer = new BufferedReader(new InputStreamReader(System.in));
		DecimalFormat df = new DecimalFormat("0.000");
		
		System.out.println("Is the beam a floorbeam [true/false]:");
		boolean type = Boolean.parseBoolean(inputbuffer.readLine());
		System.out.println("Give the length of the beam [inches]:");
		double length = Double.parseDouble(inputbuffer.readLine());
		
		System.out.println("The max deflection [inches]=" + df.format(maxDeflect(length, type)));
	}
	
	/*
	 * Calculates the maximum deflection allowed of a beam
	 * 
	 * pass the length of the beam and the type (floorbeam or not)
	 * returns the max deflection in inches in a double
	 */
	public static double maxDeflect(double length, boolean floorbeam){
		double deflection;
		
		if(floorbeam) {
			deflection = (length/240);
		} else {
			deflection = (length/180);
		}
		return deflection;
	}

}